# -*- coding: utf-8 -*-

"""
DateTime   : 2020/12/17 19:23
Author     : ZhangYafei
Description: 
"""


def odd_func(start=1, end=10):
    for val in range(start, end + 1):
        if val % 2 == 1:
            yield val


of = odd_func(1, 5)
print(of)  # <generator object odd_func at 0x00000132300C85C8>
print(next(of)) # 1
print(next(of)) # 3
print(next(of)) # 5
print(next(of))
"""
Traceback (most recent call last):
  File "D:/python/Python之路/6 生成器迭代器生成式/code/example2.py", line 21, in <module>
    print(next(of))
StopIteration
"""